﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework; // Vector2 e demais classes para posicionamento.
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
namespace first_project
{
    class ShotDistanceTraveled
    {    //Used to know what the max allowed distance of travel is from point of fire
        Vector2 maxTravel;
        Vector2 previousMaxTravel;

        Vector2 pointOrigin;
        GameWindow Window;
        /// <summary>
        /// Constructor for object distance check
        /// </summary>
        /// <param name="window">Game window size</param>
        /// <param name="pointOrigim">Position of origin for the object</param>
        public ShotDistanceTraveled(GameWindow window, Vector2 pointOrigim)
        {
            previousMaxTravel = Vector2.Zero;
            this.Window = window;
            this.pointOrigin = pointOrigim;
            maxTravel =this.pointOrigin - new Vector2(window.ClientBounds.Width, 
                window.ClientBounds.Height);
        }


        /// <summary>
        /// Check to see if object has traveled required distance in order to be destroyed
        /// </summary>
        /// <param name="position">Current position of the object</param>
        /// <returns></returns>
        public bool CheckDistance(Vector2 position)
        {
            maxTravel += position;
            //TODO: fix the bug that makes the shot go on for infinity when fired in the
            //negative axis.
            if (maxTravel.X >= Window.ClientBounds.Width ||
                (maxTravel.Y >= Window.ClientBounds.Height))
            {
                return true;
            }
            else if (maxTravel.X < Window.ClientBounds.Width ||
                (maxTravel.Y < Window.ClientBounds.Height))
            {
                return false;
            }
           
            return false;

            

        }



    }
}
